home *** CD-ROM | disk | FTP | other *** search
- /*
- CmyFileManager.c
-
- this is the methods file for my file manager object.
-
- */
- #include "oops.h"
- #include "MessageDefines.h"
- #include "Global.h"
- #include "CmyFileManager.h"
- #include "CApplication.h"
-
- /**** Global Variables ****/
-
- extern CApplication *gApplication; /* Application object */
-
- extern OSType gSignature;
-
- /* ..................................................................... */
- void CmyFileManager::ImyFileManager(void)
- /*
- Name: Wade Maxfield
- Date: November 25, 1989
- Notes:
- initalize this object
- Modification History:
- */
- {
-
- /* call the superclass function */
- CDataFile::IDataFile();
- }
-
- /* ..................................................................... */
- short CmyFileManager::GetExistingFile(SFReply *macSFReply)
- /*
- Name: Wade Maxfield
- Date: November 25, 1989
- Notes:
- put up the SFGetFile dialog box, return result in macSFReply
- return a good message(ACK) or a bad message (NAK)
- Modification History:
- */
- {
-
- gApplication->ChooseFile(macSFReply);
-
- if ( !macSFReply->good )
- return(NAK);
- else
- return(ACK);
- }
- /* ..................................................................... */
- short CmyFileManager::GetNewFile(SFReply *macSFReply,OSType fType)
- /*
- Name: Wade Maxfield
- Date: November 25, 1989
- Notes:
- put up the SFPutFile dialog box, return result in macSFReply
- create the chosen file, or recreate it.
- return a good message(ACK) or a bad message (NAK)
- Modification History:
- */
- {
- Point corner; /* Top left corner of dialog box */
- SignedByte saveHState;
- short returnMessage;
- /* Center dialog box on the screen */
- FindDlogPosition('DLOG', gApplication->sfGetDLOGid, &corner);
-
- saveHState = HGetState(this);
- HLock(this);
-
- SFPutFile(corner,"\pSave file as:","\p",NULL,macSFReply);
-
- HSetState(this, saveHState);
-
- /* now create the file for a future open.
- these methods are inherited. */
- if ( macSFReply->good)
- {
- SFSpecify(macSFReply);
- returnMessage = CreateNew(gSignature, fType );
-
- /* if is a duplicate, and user said ok to delete old,
- then go ahead and re do it */
- if ( returnMessage == dupFNErr && macSFReply->good)
- {
- ThrowOut(); /* get rid of old file */
- returnMessage = CreateNew(gSignature, fType );
- }
- }
-
- if ( !macSFReply->good || returnMessage < 0)
- return(NAK);
- else
- return(ACK);
-
- }
- /* ..................................................................... */
- short CmyFileManager::OpenFile(CmyDataFile **newDataFileObject,
- SFReply *macSFReply)
- /*
- Name: Wade Maxfield
- Date: November 25, 1989
- Notes:
- Create a myDataFile object, and open the file, hand it back to
- the calling method.
- return a good message(ACK) or a bad message (NAK)
- Modification History:
- */
- {
- short returnMessage;
-
- /* create the new file object */
- *newDataFileObject = NULL; /* to allow test for object create */
- *newDataFileObject = new(CmyDataFile);
-
- if (!(long)(*newDataFileObject)) /* object wasn't created */
- return(NAK);
-
- (*newDataFileObject)->ImyDataFile();
-
- /* tell the inherited routine what file we have */
- (*newDataFileObject)->SFSpecify(macSFReply);
-
- returnMessage = (*newDataFileObject)->Open(fsRdWrPerm); /* call the inherited open */
-
- if ( returnMessage < 0 )
- return(NAK); /* indicate an error (NAK) */
-
-
- return(ACK); /* return a good message */
- }
-
- /* ..................................................................... */
- short CmyFileManager::CloseFile(CmyDataFile **dataFileObject)
- /*
- Name: Wade Maxfield
- Date: November 25, 1989
- Notes:
- Close the file and dispose of the data file object.
- return a good message(ACK)
- Modification History:
- */
- {
- /* first, close the file, then delete the file object */
- (*dataFileObject)->Close();
-
- (*dataFileObject)->Dispose(); /* close and dispose of the object */
-
- *dataFileObject = NULL; /* indicate is gone */
-
- return(ACK); /* all quiet on western front */
- }
-